/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   list_traverse.h                                    :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: Jiang <767280080@qq.com>                   +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/04/23 11:49:24 by Jiang             #+#    #+#             */
/*   Updated: 2024/04/23 11:51:14 by Jiang            ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef __list_traverse__
#define __list_traverse__

template <typename T> void List<T>::traverse(void (*visit)(T &)) {
  for (auto it = begin(); it != end(); ++it) {
    visit(*it);
  }
  // for( ListNodePosi<T> p = head->next; p != tail ; p = p->next )
  //   visit( p->data );
}

template <typename T>
template <typename VST>
void List<T>::traverse(VST &visit) {
  for (auto it = begin(); it != end(); ++it) {
    visit(*it);
  }
  // for (ListNodePosi<T> p = head->next; p != tail; p = p->next)
  //   visit(p->data);
}

#endif // !__list_traverse__
